// pages//classify/classify.js
Page({
  data: {
    select:false,
    selected:true,
    tabList:{
      "sex":['男频','女频'],
      "a":['玄幻','奇幻','武侠','仙侠','都市','历史','军事','灵异','科幻','游戏','体育','二次元','短篇']
    },
    category_books:203000,

    
  },

// 分类接口
getData :function (e) {
  var that=this;
  wx.request({
    url: 'https://m.taoyuewenhua.com/ajax/book_mall/categories',
    methods:'GET',
    header:{
      'Content-Type':'application/json '
    },success:function(res){
      that.setData({
        resdata:res.data,
      })
      console.log(res.data)
    },
    fail:function(res){
      console.log('fail');
    }
  })
},

// 小说接口男生
getData1 :function (e) {
  var that=this;
  wx.request({
    url: 'https://m.taoyuewenhua.com/ajax/book_mall/categories/101000?',
    data:{
      page:0,
      category_books:103000,
      pageSize:20
    },
    methods:'GET',
    header:{
      'Content-Type':'application/json '
    },success:function(res){
      that.setData({
        resdata:res.data,
      })
      console.log(res.data ,"小说接口")
    },
    fail:function(res){
      console.log('fail');
    }
  })
},
// 女生
getData2 :function (e) {
  var that=this;
  wx.request({
    url: `https://m.taoyuewenhua.com/ajax/book_mall/categories/201000?`,
    data:{
      page:0,
      category_books:203000,
      pageSize:20
    },
    methods:'GET',
    header:{
      'Content-Type':'application/json '
    },success:function(res){
      that.setData({
        resdata:res.data,
      })
    },
    fail:function(res){
      console.log('fail');
    }
  })
},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    this.getData1();
  },

// 小说类型选择
  select:function(e){
    var that=this;
    if(e.currentTarget.dataset.freetype==1){
      this.getData1();
      // this.select==false
      // this.selected==true
    }else{
      this.getData2();
      // this.select==true
      // this.selected==false
      console.log(e.currentTarget.dataset.freetype,'111')
    }
    console.log(that,'333')
    console.log(e,'444')
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})